home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Cafe 3
/
Visual Cafe 3.ISO
/
Vcafe
/
JFC.bin
/
JDesktopPane.java
< prev
next >
Wrap
Text File
|
1998-06-30
|
8KB
|
247 lines
/*
* @(#)JDesktopPane.java 1.17 98/03/13
*
* Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
*
* This software is the confidential and proprietary information of Sun
* Microsystems, Inc. ("Confidential Information"). You shall not
* disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into
* with Sun.
*
* SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
* SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
* SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
* THIS SOFTWARE OR ITS DERIVATIVES.
*
*/
package com.sun.java.swing;
import java.util.Vector;
import com.sun.java.swing.plaf.*;
import com.sun.java.accessibility.*;
/**
* A container used to create a multiple-document interface or a virtual desktop.
* You create JInternalFrame objects and add them to the JDesktopPane.
* JDesktopPane extends JLayeredPane to manage the potentially overlapping internal frames. It also
* maintains a reference to an instance of DesktopManager that is set by the UI
* class for the current Look and Feel (L&F).
* <p>
* This class is normally used as the parent of JInternalFrames to provide a
* pluggable DesktopManager object to the JInternalFrames. The installUI of the
* L&F specific implementation is responsible for setting the desktopManager
* variable appropriately. When the parent of a JInternalFrame is a JDesktopPane,
* it should delegate most of its behavior to the desktopManager (closing, resizing,
* etc).
* <p>
* For the keyboard keys used by this component in the standard Look and
* Feel (L&F) renditions, see the
* <a href="doc-files/Key-Index.html#JDesktopPane">JDesktopPane</a> key assignments.
* <p>
* Warning: serialized objects of this class will not be compatible with
* future swing releases. The current serialization support is appropriate
* for short term storage or RMI between Swing1.0 applications. It will
* not be possible to load serialized Swing1.0 objects with future releases
* of Swing. The JDK1.2 release of Swing will be the compatibility
* baseline for the serialized form of Swing objects.
*
* @see JInternalFrame
* @see JInternalFrame.JDesktopIcon
* @see DesktopManager
*
* @version 1.17 03/13/98
* @author David Kloba
*/
public class JDesktopPane extends JLayeredPane implements Accessible
{
DesktopManager desktopManager;
/**
* Creates a new JDesktopPane.
*/
public JDesktopPane() {
updateUI();
}
/**
* Returns the L&F object that renders this component.
*
* @return the DesktopPaneUI object that renders this component
*/
public DesktopPaneUI getUI() {
return (DesktopPaneUI)ui;
}
/**
* Sets the L&F object that renders this component.
*
* @param ui the DesktopPaneUI L&F object
* @see UIDefaults#getUI
*/
public void setUI(DesktopPaneUI ui) {
super.setUI(ui);
}
/**
* Returns the DesktopManger that handles desktop-specific UI actions.
*
* @param d the DesktopManager currently in use
*/
public DesktopManager getDesktopManager() {
return desktopManager;
}
/**
* Sets the DesktopManger that will handle desktop-specific UI actions.
*
* @param d the DesktopManager to use
*/
public void setDesktopManager(DesktopManager d) {
desktopManager = d;
}
/**
* Notification from the UIManager that the L&F has changed.
* Replaces the current UI object with the latest version from the
* UIManager.
*
* @see JComponent#updateUI
*/
public void updateUI() {
setUI((DesktopPaneUI)UIManager.getUI(this));
}
/**
* Returns the name of the L&F class that renders this component.
*
* @return "DesktopPaneUI"
* @see JComponent#getUIClassID
* @see UIDefaults#getUI
*/
public String getUIClassID() {
return "DesktopPaneUI";
}
/**
* Returns all JInternalFrames currently displayed in the
* desktop. Returns iconified frames as well as expanded frames.
*
* @return an array of JInternalFrame objects
*/
public JInternalFrame[] getAllFrames() {
int i, count;
JInternalFrame[] results;
Vector vResults = new Vector(10);
Object next, tmp;
count = getComponentCount();
for(i = 0; i < count; i++) {
next = getComponent(i);
if(next instanceof JInternalFrame)
vResults.addElement(next);
else if(next instanceof JInternalFrame.JDesktopIcon) {
tmp = ((JInternalFrame.JDesktopIcon)next).getInternalFrame();
if(tmp != null)
vResults.addElement(tmp);
}
}
results = new JInternalFrame[vResults.size()];
vResults.copyInto(results);
return results;
}
/**
* Returns all JInternalFrames currently displayed in the
* specified layer of the desktop. Returns iconified frames as well
* expanded frames.
*
* @param layer an int specifying the desktop layer
* @return an array of JInternalFrame objects
* @see JLayeredPane
*/
public JInternalFrame[] getAllFramesInLayer(int layer) {
int i, count;
JInternalFrame[] results;
Vector vResults = new Vector(10);
Object next, tmp;
count = getComponentCount();
for(i = 0; i < count; i++) {
next = getComponent(i);
if(next instanceof JInternalFrame)
if(((JInternalFrame)next).getLayer() == layer)
vResults.addElement(next);
else if(next instanceof JInternalFrame.JDesktopIcon) {
tmp = ((JInternalFrame.JDesktopIcon)next).getInternalFrame();
if(tmp != null && ((JInternalFrame)tmp).getLayer() == layer)
vResults.addElement(tmp);
}
}
results = new JInternalFrame[vResults.size()];
vResults.copyInto(results);
return results;
}
/**
* Returns true to indicate that this component paints every pixel
* in its range. (In other words, it does not have a transparent
* background or foreground.)
*
* @return true
* @see JComponent#isOpaque
*/
public boolean isOpaque() {
return true;
}
/////////////////
// Accessibility support
////////////////
/**
* Get the AccessibleContext associated with this JComponent
*
* @return the AccessibleContext of this JComponent
*/
public AccessibleContext getAccessibleContext() {
if (accessibleContext == null) {
accessibleContext = new AccessibleJDesktopPane();
}
return accessibleContext;
}
/**
* The class used to obtain the accessible role for this object.
* <p>
* Warning: serialized objects of this class will not be compatible with
* future swing releases. The current serialization support is appropriate
* for short term storage or RMI between Swing1.0 applications. It will
* not be possible to load serialized Swing1.0 objects with future releases
* of Swing. The JDK1.2 release of Swing will be the compatibility
* baseline for the serialized form of Swing objects.
*/
protected class AccessibleJDesktopPane extends AccessibleJComponent {
/**
* Get the role of this object.
*
* @return an instance of AccessibleRole describing the role of the
* object
* @see AccessibleRole
*/
public AccessibleRole getAccessibleRole() {
return AccessibleRole.DESKTOP_PANE;
}
}
}